package com.fs.web.base.command;

import com.fs.common.pojo.Modle;
import com.fs.web.base.mapper.ModleMapper;
import com.fs.web.base.param.SysConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author TiddlerCJ
 * @desc 加载模块数据
 */
@Slf4j
@Component
@Order(value=1)
public class LoadModleDataCommand implements CommandLineRunner {
	@Autowired
    private ModleMapper modleMapper;

	@Override
	public void run(String... args) throws Exception {
		/*
		 * 加载Modle所有数据
		 */
		List<Modle> modleList = modleMapper.selectList(null);
		for(Modle m: modleList){
			SysConstant.MODLE_CLASSNAME.put(m.getModleName(), m.getClassName());
		}
		log.info(" Load ALL Data success! ");
	}
	
}
